package com.milo.thread.code;

import org.junit.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 多线程面试题
 * @author milogenius
 * @date 2020-04-20 17:26
 * <p>
 *     要求用三个线程，线程1先打印1,2,3,4,5, 然后是线程2打印6,7,8,9,10, 然后是线程3打印11,12,13,14,15.
 *     接着再由线程1打印16,17,18,19,20....以此类推，直到输出到45
 * </p>
 */
public class InterviewCodeOne {

    @Test
    public void test1(){
        Object lockObj = new Object();
        ExecutorService threadPool = Executors.newFixedThreadPool(3);
        threadPool.execute(new MyRunableOne(0,lockObj));
        threadPool.execute(new MyRunableOne(1,lockObj));
        threadPool.execute(new MyRunableOne(2,lockObj));
        threadPool.shutdown();
    }

}
